import request from '@/utils/request'

// 查询优惠券活动列表
export function listActivity(query) {
  return request({
    url: '/merchant/activity/list',
    method: 'get',
    params: query
  })
}

// 查询优惠券活动详细
export function getActivity(id) {
  return request({
    url: '/merchant/activity/' + id,
    method: 'get'
  })
}

// 新增优惠券活动
export function addActivity(data) {
  return request({
    url: '/merchant/activity',
    method: 'post',
    data: data
  })
}

// 修改优惠券活动
export function updateActivity(data) {
  return request({
    url: '/merchant/activity',
    method: 'put',
    data: data
  })
}

// 删除优惠券活动
export function delActivity(id) {
  return request({
    url: '/merchant/activity/' + id,
    method: 'delete'
  })
}

// 导出优惠券活动
export function exportActivity(query) {
  return request({
    url: '/merchant/activity/export',
    method: 'get',
    params: query
  })
}


// 上传视频
export function uploadVideo(data) {
  return request({
    url: '/system/user/profile/avatar',
    method: 'post',
    data: data
  })
}
export function uploadImg(data) {
  /*return request({
    url: '/merchant/merchant/uploadVideo',
    method: 'post',
    data: data
  })*/
  return request({
    url: '/system/user/profile/avatar',
    method: 'post',
    data: data
  })
  }
// 下架活动
export function offlineActivity(ids) {
  var url = '/merchant/activity/offline?';

  if (ids instanceof Array) {
    for (var i = 0; i < ids.length; i++) {
      var id = ids[i];
      url = url + "ids=" + id + "&";
    }
  } else {
    url = url + "ids=" + ids;
  }
  return request({
    url: url,
    method: 'get',
  })
}
// 上线活动
export function onlineActivity(ids) {
  var url = '/merchant/activity/online?';

  if (ids instanceof Array) {
    for (var i = 0; i < ids.length; i++) {
      var id = ids[i];
      url = url + "ids=" + id + "&";
    }
  } else {
    url = url + "ids=" + ids;
  }
  return request({
    url: url,
    method: 'get',
  })
}
